package Day15.poly_.six.Testpro;



/**
 * @author HYHwtx
 * @version 1.0
 * @date 2022/2/22 17:52
 */
public class PersonTest {
    public static void main(String[] args) {
        Person[] person = new Person[5];
        person[0] = new Person("张三", 45);
        person[1] = new Student("李四", 36, 25);
        person[2] = new Student("王五", 39, 89);
        person[3] = new Teacher("二哈", 75, 4589.5);
        person[4] = new Teacher("拉布拉多", 25, 9678);
        for (int i = 0; i < person.length; i++) {
            System.out.println(person[i].say());

            if (person[i] instanceof Student){//判断person[i]运行类型是不是Student
                Student student =(Student)person[i];//向下转型
                student.study();
            }else if (person[i] instanceof  Teacher){
                Teacher teacher =(Teacher)person[i];
                teacher.teach();
            }else {
                System.out.println("您的类型有误，请自行检查！！！");
            }
        }
    }
}